package container
{
	import baseInterface.container.IBaseSkinContainer;
	import baseInterface.container.ImultSkinContainer;
	
	import flash.display.DisplayObjectContainer;
	
	import gridlayout.BaseLayout;
	
	import skin.BaseSkin;
	
	public class ADmultSkinContain implements ImultSkinContainer
	{
		protected var skinContainerVec:Vector.<IBaseSkinContainer>=new Vector.<ADBaseSkinContain>;
		private var _len:int;
		private var _max:int;
		
		public function ADmultSkinContain()
		{
			super();
		}
		public function get maxLen():int
		{
			return _max;
		}
		public function get skinLen():int
		{
			return skinContainerVec.length;
		}

		public function set skinLen(value:int):void
		{
			_len = value;
		}

		public function getskinContainerByindex(index:int):IBaseSkinContainer
		{
			if(index>=skinLen||index>=skinContainerVec.length||index<0)
				return null
			return skinContainerVec[index];
		}
		public function setSkinByIndex(index:int,skin:BaseSkin):IBaseSkinContainer
		{
			if(index<0||index>=skinLen)return null;
			var skinc:ADBaseSkinContain=new ADBaseSkinContain();
			skinc.skin=skin;
			skinContainerVec[index]=skinc;
			return skinc;
		}
		private var grid:BaseLayout;
		public function rePosition(style:int):void
		{
			grid||=new BaseLayout();
			grid.addEntityArray(skinContainerVec);
			grid.update();
		}
		public 	function setContainer(target:DisplayObjectContainer):void
		{
			if(target)
			{
				for each (var i:IBaseSkinContainer in skinContainerVec) 
				{
					target.addChild(i.skin);
				}
				
			}
		}
		
	}
}